package com.onec.service.trade.service.kafka;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Component;

/**
 * 卡夫卡服务接收端
 */
@Component
@EnableBinding(Sink.class)
public class ReceiveService {

  @StreamListener(Sink.INPUT)
  public void receive(Message<String> message) {
    System.out.println("stream 监听以及接收kafka: 监听到的内容为：{}" + JSON.toJSONString(message.getPayload()));
  }
}
